#include "wx/wxprec.h"
#include "wx/xrc/xh_hyperlink.h"
#include "wx/hyperlink.h"
#include "wx/xrc/xmlres.h"

IMPLEMENT_DYNAMIC_CLASS( wxHyperlinkCtrlXmlHandler, wxXmlResourceHandler )

wxHyperlinkCtrlXmlHandler::wxHyperlinkCtrlXmlHandler() {
  XRC_ADD_STYLE( wxHL_CONTEXTMENU );
  XRC_ADD_STYLE( wxHL_ALIGN_LEFT );
  XRC_ADD_STYLE( wxHL_ALIGN_RIGHT );
  XRC_ADD_STYLE( wxHL_ALIGN_CENTRE );
  XRC_ADD_STYLE( wxHL_DEFAULT_STYLE );
  AddWindowStyles();
}

wxObject *wxHyperlinkCtrlXmlHandler::DoCreateResource() {
  XRC_MAKE_INSTANCE( control, wxHyperlinkCtrl )
  control->Create
  (
    m_parentAsWindow,
    GetID(),
    GetText( wxT( "label" ) ),
    GetParamValue( wxT( "url" ) ),
    GetPosition(), GetSize(),
    GetStyle( wxT( "style" ), wxHL_DEFAULT_STYLE ),
    GetName()
  );
  SetupWindow( control );
  return control;
}

bool wxHyperlinkCtrlXmlHandler::CanHandle( wxXmlNode *node ) {
  return IsOfClass( node, wxT( "wxHyperlinkCtrl" ) );
}
